package com.kugong.match;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * mysql> desc tb_match;
 +-------------+-------------+------+-----+---------+----------------+
 | Field       | Type        | Null | Key | Default | Extra          |
 +-------------+-------------+------+-----+---------+----------------+
 | id          | int(11)     | NO   | PRI | NULL    | auto_increment |
 | name        | varchar(50) | YES  |     | NULL    |                |
 | ownerId     | varchar(10) | YES  |     | NULL    |                |
 | signUpTime  | datetime    | YES  |     | NULL    |                |
 | closingTime | datetime    | YES  |     | NULL    |                |
 | playerNum   | int(11)     | NO   |     | NULL    |                |
 | state       | varchar(10) | YES  |     | NULL    |                |
 | type        | varchar(10) | YES  |     | NULL    |                |
 | createTime  | datetime    | YES  |     | NULL    |                |
 +-------------+-------------+------+-----+---------+----------------+
 * Created by Administrator on 2015/8/4.
 */
public class Match extends Model<Match> {
    public final static Match dao = new Match();

    public Page<Match> paginate(int page,int size){
        return paginate(page,size,"select m.*, (select count(1) from tb_sign_up s where s.matchId=m.id) as signUpNum", "from tb_match m order by id desc");
    }
}
